using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Tool.Model;
using Tool.Utilty;

namespace Tool.BaseClass
{
	public class GClass0
	{
		public static string UserAgent
		{
			get
			{
				GClass27 gClass = GClass28.smethod_1();
				string result = "";
				if (gClass != null)
				{
					result = GClass0.smethod_14((GClass26.GEnum3)gClass.UserAgent);
				}
				return result;
			}
		}

		public static bool smethod_0(string string_0)
		{
			bool flag = true;
			string text = "";
			try
			{
				Clipboard.Clear();
				Clipboard.SetText(string_0);
			}
			catch
			{
				try
				{
					Clipboard.Clear();
					Clipboard.SetText(string_0);
				}
				catch (Exception ex)
				{
					text = ex.Message.ToString();
					flag = false;
				}
			}
			if (!flag)
			{
				MessageBox.Show(text);
			}
			return flag;
		}

		public static void smethod_1(Hashtable hashtable_0, string string_0, string string_1)
		{
			if (!hashtable_0.smethod_3(string_0))
			{
				hashtable_0.Add(string_0, string_1);
			}
		}

		public static void smethod_2(Hashtable hashtable_0, string string_0, string string_1)
		{
			string_1 = string_1.Split(new char[]
			{
				'#'
			})[0];
			if (!hashtable_0.smethod_3(string_0))
			{
				hashtable_0.Add(string_0.Trim(), string_1.Replace("/", "\\").Trim());
			}
		}

		public static bool smethod_3(Hashtable hashtable_0, GClass26.GEnum2 genum2_0, string string_0, string string_1, string string_2, ref string string_3)
		{
			bool result = true;
			if (!hashtable_0.ContainsKey(string_0))
			{
				try
				{
					string_0 = string_0.Split(new char[]
					{
						'?'
					})[0].ToLower();
					string text = Path.GetFileNameWithoutExtension(string_0).ToLower();
					string text2 = Path.GetExtension(string_0).ToLower();
					if (!(text != "") || !(text2 != ""))
					{
						string_3 = Guid.NewGuid().ToString("N") + "." + genum2_0.ToString().ToLower();
					}
					else
					{
						if ((genum2_0 == GClass26.GEnum2.css || genum2_0 == GClass26.GEnum2.js) && text2.ToLower() != "." + genum2_0.ToString().ToLower())
						{
							text2 = "." + genum2_0.ToString();
						}
						string_3 = text + text2;
						int num = 1;
						while (hashtable_0.ContainsValue(string_1 + string_2 + string_3) || File.Exists(string_1 + string_2 + string_3))
						{
							string_3 = text + "_" + num.ToString() + text2;
							num++;
						}
					}
					return result;
				}
				catch
				{
					string_3 = Guid.NewGuid().ToString("N") + "." + genum2_0.ToString().ToLower();
					return result;
				}
			}
			string_3 = Path.GetFileName(hashtable_0[string_0].ToString());
			result = false;
			return result;
		}

		public static void smethod_4(List<GClass19.GClass21> list_0, string string_0, GClass19.GClass21.GEnum0 genum0_0)
		{
			list_0.Add(new GClass19.GClass21
			{
				Message = string_0,
				Category = genum0_0
			});
		}

		public static string smethod_5(string string_0)
		{
			string_0 = string_0.Replace("&amp;", "&");
			return string_0.Trim();
		}

		public static bool smethod_6(ref string string_0, List<GClass19.GClass21> list_0, string string_1, string string_2)
		{
			bool result;
			try
			{
				string_0 = new System.Uri(new System.Uri(string_2), string_1).ToString();
				result = true;
			}
			catch
			{
				GClass0.smethod_4(list_0, "转URI地址失败：" + string_1, GClass19.GClass21.GEnum0.ConvertURIFail);
				result = false;
			}
			return result;
		}

		public static void smethod_7(System.Net.HttpWebRequest httpWebRequest_0, string string_0)
		{
			string value = null;
			try
			{
				value = new System.Uri(string_0).Host.Trim();
			}
			catch
			{
			}
			if (!string.IsNullOrEmpty(value))
			{
			}
		}

		public static bool smethod_8(string string_0)
		{
			System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^/$|^/(.+)/$", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Singleline);
			bool result;
			if (regex.Matches(string_0).Count <= 0)
			{
				result = false;
			}
			else
			{
				string[] array = string_0.Split(new char[]
				{
					'/'
				});
				if (array.Length > 0)
				{
					bool flag = true;
					for (int i = 1; i < array.Length - 1; i++)
					{
						if (array[i].Trim() == "" || !array[i].Trim().smethod_8())
						{
							flag = false;
							//IL_8E:
							result = flag;
							return result;
						}
					}
					//goto IL_8E;
				}
				result = true;
			}
			return result;
		}

		public static bool smethod_9(string string_0)
		{
			bool result = true;
			if (string_0 == "" || !string_0.smethod_8())
			{
				result = false;
			}
			return result;
		}

		public static string smethod_10(string string_0, string string_1)
		{
			string[] array = string_0.Split(new char[]
			{
				'/'
			});
			string[] array2 = string_1.Split(new char[]
			{
				'/'
			});
			int num = (array.Length < array2.Length) ? array.Length : array2.Length;
			int num2 = -1;
			int i = 0;
			while (i < num && array[i] == array2[i])
			{
				num2 = i;
				i++;
			}
			string str = "";
			for (i = 0; i < array.Length; i++)
			{
				if (i > num2 + 1)
				{
					str += "../";
				}
			}
			string text = "";
			for (i = num2 + 1; i < array2.Length; i++)
			{
				text = text + "/" + array2[i];
			}
			if (text.Length > 0)
			{
				text = text.Substring(1);
			}
			return str + text;
		}

		public static string smethod_11(string string_0, string string_1)
		{
			string str = "<!DOCTYPE html>";
			str += "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
			str += "<head>";
			str += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
			str += "<title></title>";
			str += "<style type=\"text/css\">";
			str += "body { background-color: #fff; color: #222; font-family:'微软雅黑', Verdana, Tahoma, Arial; font-size: 12px; padding: 2px; margin: 0px; }";
			str += "* { color: #222; font-family:'微软雅黑', Verdana, Tahoma, Arial; font-size: 12px; }";
			str += ".bd { margin: 0px 1px 1px 1px; padding: 0px; background: #fff; }";
			str += ".title { padding: 0px; margin: 0px; height: 28px; width: 100% !important; text-align: left; font-size: 14px; background: #D3E5F8 url() repeat-x; border: 0px; }";
			str += ".title1 { float: left; margin: 0px 0px 0px 3px; padding: 5px 0px 0px 0px; height: 21px; font-weight:bold;}";
			str += ".tablelistnowrap { border-left: 1px solid #BFD9F5; border-top: 1px solid #BFD9F5; width: 100%; margin-top: 1px; background: #fff; font-size: 12px; font-weight: normal; line-height: 25px; text-align: left; }";
			str += ".tablelistnowrap th, .tablelistnowrap td { border-bottom: 1px solid #BFD9F5; border-right: 1px solid #BFD9F5; padding: 3px; line-height: 16px; height: 25px; }";
			str += ".tablelistnowrap th { background: #E3F0FE; text-align: left; }";
			str += "a:{ text-decoration: underline;}";
			str += "a:link { color: blue; }";
			str += "a:visited { color: #c00; }";
			str += "a:hover { color: #69f; }";
			str += "a:active { color: #369; }";
			str += "</style>";
			str += "</head>";
			str += "<body class=\"bd\">";
			str += "<div class=\"title\">";
			str = str + "<span class=\"title1\">" + string_0 + "</span>";
			str += "</div>";
			str += string_1;
			str += "</body>";
			return str + "</html>";
		}

		public static string smethod_12(string string_0)
		{
			return SecurityElement.Escape(string_0);
		}

		public static string smethod_13(int int_0)
		{
			GClass27 gClass = GClass28.smethod_1();
			gClass.UserAgent = int_0;
			return GClass0.smethod_14((GClass26.GEnum3)int_0);
		}

		private static string smethod_14(GClass26.GEnum3 genum3_0)
		{
			string result = "";
			switch (genum3_0)
			{
			case GClass26.GEnum3.PcChrome34:
				result = "mozilla/5.0 (windows nt 6.1) applewebkit/537.36 (khtml, like gecko) chrome/34.0.1847.131 safari/537.36";
				break;
			case GClass26.GEnum3.PcFireFox30:
				result = "mozilla/5.0 (windows nt 6.1; rv:30.0) gecko/20100101 firefox/30.0";
				break;
			case GClass26.GEnum3.PcIE10:
				result = "mozilla/5.0 (compatible; msie 9.0; qdesk 2.4.1265.203; windows nt 6.1; trident/6.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; .net4.0c; .net4.0e; infopath.3) ";
				break;
			case GClass26.GEnum3.PcWeiXin:
			case GClass26.GEnum3.MobileWeiXin:
				result = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat";
				break;
			case GClass26.GEnum3.iPhoneIOS:
				result = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en-us) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3";
				break;
			case GClass26.GEnum3.iPhoneIOS2:
				result = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5A347 Safari/52";
				break;
			case GClass26.GEnum3.iPhoneIOS3:
				result = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
				break;
			case GClass26.GEnum3.iPhoneIOS4:
				result = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5";
				break;
			case GClass26.GEnum3.iPhoneIOS5:
				result = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334 Safari/7534.48.3";
				break;
			case GClass26.GEnum3.iPhoneIOS6:
				result = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25";
				break;
			case GClass26.GEnum3.iPodIOS2:
				result = "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3";
				break;
			case GClass26.GEnum3.iPodIOS4:
				result = "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B118 Safari/6531.22.7";
				break;
			case GClass26.GEnum3.iPodIOS5:
				result = "Mozilla/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3";
				break;
			case GClass26.GEnum3.iPadIOS3:
				result = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10";
				break;
			case GClass26.GEnum3.iPadIOS4:
				result = "Mozilla/5.0 (iPad; U; CPU OS 4_2 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8C134";
				break;
			case GClass26.GEnum3.iPadIOS5:
				result = "Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3";
				break;
			case GClass26.GEnum3.iPadIOS6:
				result = "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25";
				break;
			case GClass26.GEnum3.AndroidOS15:
				result = "Mozilla/5.0 (Linux; U; Android 1.5; en-us; GDDJ-09 Build/CDB56) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1";
				break;
			case GClass26.GEnum3.AndroidOS16:
				result = "Mozilla/5.0 (Linux; U; Android 1.6; en-us; IS01 Build/S3082) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1";
				break;
			case GClass26.GEnum3.AndroidOS2x:
				result = "Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; SonyEricssonSO-01B Build/2.0.2.B.0.29) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17";
				break;
			case GClass26.GEnum3.AndroidOS3x:
				result = "Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; MZ604 Build/H.6.2-20) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13";
				break;
			case GClass26.GEnum3.AndroidOS4x:
				result = "Mozilla/5.0 (Linux; U; Android 4.0.1; en-us; Galaxy Nexus Build/ITL41D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";
				break;
			case GClass26.GEnum3.AndroidOpera:
				result = "Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; en-us) Presto/2.9.201 Version/11.50";
				break;
			case GClass26.GEnum3.AndroidFirefox:
				result = "Mozilla/5.0 (Android; Linux armv7l; rv:9.0) Gecko/20111216 Firefox/9.0 Fennec/9.0";
				break;
			case GClass26.GEnum3.WindowsPhoneOS6x:
				result = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; KDDI-TS01; Windows Phone 6.5.3.5)";
				break;
			case GClass26.GEnum3.WindowsPhoneOS7x:
				result = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; FujitsuToshibaMobileCommun; IS12T; KDDI)";
				break;
			}
			return result;
		}
	}
}
